<!-- ************************************************************************************************************ -->
<!-- fileName          : client_topguide_display.jsp 															  -->
<!-- summary           : client端  顶部导航  页面显示 																	  -->
<!-- ************************************************************************************************************ -->

<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page import="java.sql.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="/immigration/css/guide.css" />
<link rel="stylesheet" type="text/css" href="/immigration/css/bootstrap/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="/immigration/css/bootstrap/bootstrap-responsive.min.css" />
<link rel="stylesheet" type="text/css" href="/immigration/css/layout.css">
<script type="text/javascript" src="/immigration/js/jquery.js"></script>
<script type="text/javascript" src="/immigration/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/immigration/js/guide.js"></script>
<title>Immigration Explore | 探索移民</title>
<style type="text/css">
.main-connent,.right {
	margin-top: 60px;
}

.content {
	padding: 5px 50px;
	overflow: auto;
}

.main-connent {
	width: 75%;
	float: left;
	font-size: 13px;
	line-height: 14px;
	border-radius: 4px;
	box-shadow: 0 0 10px #ccc;
}

.right {
	width: 23%;
	float: right;
	font-size: 13px;
	line-height: 13px;
	border-radius: 4px;
	box-shadow: 0 0 10px #ccc;
}

.main-connent .main-left {
	width: 76%;
	float: left;
}

.main-connent .main-mid {
	width: 23%;
	float: right;
}

.main-connent .main-left .main-left-top {
	width: 100%;
}

.main-connent .main-left .main-left-bottom {
	width: 100%;
}

.main-left-bottom.main-bottom-left {
	width: 30%;
	float: left;
}

.main-left-bottom.main-bottom-right {
	width: 30%;
	float: right;
}

.main-connent .main-mid  .main-mid-top {
	width: 100%
}

.main-connent .main-mid  .main-mid-bottom {
	width: 100%
}

.title-icon {
	padding: 5px 15px;
	border-bottom: #fff 1px solid;
	color: #000000;
	font-weight: bold;
	font-size: 14px;
}

p {
	display: block;
	-webkit-margin-before: 0px;
	-webkit-margin-after: 0px;
	-webkit-margin-start: 0px;
	-webkit-margin-end: 0px;
	padding: 0 20px;
	margin:0;
}

</style>

</head>
<body>
<%
	//设置请求的字符编码以支持中文
	request.setCharacterEncoding ("utf-8");
	
	//获取请求参数
	String currentId = request.getParameter("CId");
	String faherId =  request.getParameter("FId");
	
	//从web.xml获取全局参数
	String drv=config.getServletContext().getInitParameter("DBDriver");
	String url=config.getServletContext().getInitParameter("DBURL");
	String uid=config.getServletContext().getInitParameter("DBUser");
	String pwd=config.getServletContext().getInitParameter("DBPass");
	
	//构建SQL字符串和JDBC对象
	String strSQL1 = "SELECT * FROM immie0_immi.topguide t WHERE t.id=?";	// (id, name, content_name, content, url, father_id, date)
	String strSQL2 = "SELECT * FROM immie0_immi.topguide t WHERE t.father_id=?";		// (id, name, content_name, content, url, father_id, date) 
	String strSQL3 = "SELECT * FROM immie0_immi.topguide t WHERE t.father_id=?";   	// (id, name, content_name, content, url, father_id, date)
	String strSQL4 = "SELECT * FROM immie0_immi.contentlink cl WHERE cl.father_id=-1";	// (id, name, content_name, content, url, father_id, date)
	
	Connection conn = null;
	PreparedStatement pstmt1 = null;	
	PreparedStatement pstmt2 = null;
	PreparedStatement pstmt3 = null;
	PreparedStatement pstmt4 = null;
	ResultSet rs1 = null; //要显示的页面id
	ResultSet rs2 = null; //左侧导航子节点
	ResultSet rs3 = null; //左侧导航子子节点
	ResultSet rs4 = null; //文章标题处常用链接
 
	try {
		Class.forName(drv).newInstance();
		conn = DriverManager.getConnection(url,uid,pwd);
		pstmt1 = conn.prepareStatement(strSQL1);		
		//设置SQL语句的参数
		pstmt1.setString(1, currentId);	
		rs1 = pstmt1.executeQuery();
		rs1.next();

		if( !rs1.getString(4).isEmpty() && rs1.getString(5).equals("NULL")){ //content非空， url=NULL，内部页面		%>

	<div>
	<jsp:include page="/page/client/client_top.jsp"></jsp:include>
	</div>
	
	<div id="mainContent">
	
		<div id="sidebar">
			<div class="pnav-cnt">
<%
		pstmt2 = conn.prepareStatement(strSQL2);		
		//设置SQL语句的参数
		pstmt2.setString(1, faherId);	
		rs2 = pstmt2.executeQuery();	//执行查询
			
		while(rs2.next()) {
%>
				<div class="pnav-box" id="letter-a">
					<div class="box-title">
						<a class="btn-fold hidden" href="#"></a> 
						<a class="btn-unfold" href="#"></a> 
<% 						if( !rs2.getString(4).isEmpty() && rs2.getString(5).equals("NULL")){ //content非空， url=NULL，内部页面	
%>						<a href="/immigration/page/client/client_topguide_display.jsp?CId=<%=rs2.getString(1)%>&FId=<%=rs2.getString(6)%>"><span class="pnav-letter"><%=rs2.getString(2)%></span></a>
<%						}
						if( rs2.getString(4).equals("NULL") && !rs2.getString(5).isEmpty() ){ //content=NULL， url非空，外部链接	
%>						<a href="<%=rs2.getString(5)%>" target="_blank" ><span class="pnav-letter"><%=rs2.getString(2)%></span></a>
<%						}
%>					</div>
<%	
			pstmt3 = conn.prepareStatement(strSQL3);
			//设置SQL语句参数
			pstmt3.setString(1, rs2.getString(1) );
							
			rs3 = pstmt3.executeQuery();
							
			if(rs3.next()) {			%>
								
					<ul class="box-list">
						<li style="padding:0 10px;">
<% 						if( !rs3.getString(4).isEmpty() && rs3.getString(5).equals("NULL")){ //content非空， url=NULL，内部页面	
%>							<b> <a href="/immigration/page/client/client_topguide_display.jsp?CId=<%=rs3.getString(1)%>&FId=<%=rs2.getString(6)%>" ><%=rs3.getString(2) %></a></b>
<%						}
						if( rs3.getString(4).equals("NULL") && !rs3.getString(5).isEmpty() ){ //content=NULL， url非空，外部链接	
%>							<b> <a href="<%=rs3.getString(5)%>" target="_blank" ><%=rs3.getString(2) %></a></b>
<%						}
%>							<span class="cDGray"> </span>											
						</li>	
<% 			}
							
			while(rs3.next()) { 		%>
						
						<li style="padding:0 10px;">
<% 						if( !rs3.getString(4).isEmpty() && rs3.getString(5).equals("NULL")){ //content非空， url=NULL，内部页面	
%>							<b> <a href="/immigration/page/client/client_topguide_display.jsp?CId=<%=rs3.getString(1)%>&FId=<%=rs2.getString(6)%>" ><%=rs3.getString(2) %></a></b>
<%						}
						if( rs3.getString(4).equals("NULL") && !rs3.getString(5).isEmpty() ){ //content=NULL， url非空，外部链接	
%>							<b> <a href="<%=rs3.getString(5)%>" target="_blank" ><%=rs3.getString(2) %></a></b>
<%						}
%>							<span class="cDGray"> </span>											
						</li>
<%			}//第二个while 结束			%>
					</ul>
				</div>
<% 		}	//第一个while 结束		%>
			<script type="text/javascript">
				//<![CDATA[ 
					(function() {
						NTES("span.photo-search input[type=text]")
							.addEvent(
								"focus",
								function() {
									this.value == this.defaultValue
											&& (this.value = "");
								})
							.addEvent(
								"blur",
								function() {
									this.value == ""
											&& (this.value = this.defaultValue);
								});
						NTES("div.pnav-box div.box-title a.btn-fold")
							.addEvent(
								"click",
								function(e) {
									e.preventDefault();
									var eleTitle = NTES(this.parentNode);
									NTES(this).addCss("hidden");
									eleTitle.$("a.btn-unfold")
											.removeCss("hidden");
									NTES(eleTitle.parentNode).$(
											"ul.box-list")
											.removeCss("hidden");
								});
						NTES("div.pnav-box div.box-title a.btn-unfold")
							.addEvent(
								"click",
								function(e) {
									e.preventDefault();
									var eleTitle = NTES(this.parentNode);
									NTES(this).addCss("hidden");
									eleTitle.$("a.btn-fold")
											.removeCss("hidden");
									NTES(eleTitle.parentNode).$(
											"ul.box-list").addCss(
											"hidden");
								});
						NTES("div.pnav-box ul.box-list a.btn-fold")
							.addEvent(
								"click",
								function(e) {
									e.preventDefault();
									var eleTitle = NTES(this.parentNode);
									NTES(this).addCss("hidden");
									eleTitle.$("a.btn-unfold")
											.removeCss("hidden");
									eleTitle.$("p").removeCss(
											"hidden");
								});
						NTES("div.pnav-box ul.box-list a.btn-unfold")
							.addEvent(
								"click",
								function(e) {
									e.preventDefault();
									var eleTitle = NTES(this.parentNode);
									NTES(this).addCss("hidden");
									eleTitle.$("a.btn-fold")
											.removeCss("hidden");
									eleTitle.$("p")
											.addCss("hidden");
								});
						new NTES.ui.Slide(NTES("ul.photo-snav li"),
								NTES("div.photo-scnt"), "active",
								"mouseover", 6000);
					})();
					//]]>
				</script>
			</div>
		</div>
	
		<div id="tabcontent" style=" min-height:748px; margin:0 0 0 187px !important; border-top:#dcdddd 1px solid; border-left:#dcdddd 1px solid; border-right:#dcdddd 1px solid; background-image: url(/immigration/image/client_bg.png);">
			
			<div id="content-title">
				<font><%=rs1.getString(3) %></font>
			</div>
			
			<div  id="content-timeline">
			 	<font style="font-family: Microsoft YaHei;	font-size:15px; float:left;">修改时间：<%=rs1.getDate(7) %></font>
			 	<div style="float:left;">
			 		<font style="font-family: Microsoft YaHei;	font-size:15px; margin-left:20px;">常用链接：</font>
<% 					
			pstmt4 = conn.prepareStatement(strSQL4);		
							
			rs4 = pstmt4.executeQuery();			
			while(rs4.next()) {						%>
					<a href="/immigration/page/client/client_contentlink_display.jsp?CId=<%=rs4.getString(1) %>" ><%=rs4.getString(2) %></a>
<%			}		%>	
				</div>		 		
			</div>
			
			<div id="content-content"><%=rs1.getString(4) %></div> 	
			
		</div>	
		<br class="clearfloat" /> 
	</div>
	
	<div>
	<jsp:include page="/page/footer.jsp"></jsp:include>
	</div>
<%		}
		if( rs1.getString(4).equals("NULL") && !rs1.getString(5).isEmpty() ){ //content=NULL， url非空，外部链接	 	%>			
		
		<script language="javascript">
		<!-- 
		window.open ("<%=rs1.getString(5) %>","_self");		
		--> 
		</script>

<%		}	
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
		    e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		} 
		finally {
			if (rs1 != null) {
				rs1.close();
				rs1 = null;
			}
			if (rs2 != null) {
				rs2.close();
				rs2 = null;
			}
			if (rs3 != null) {
				rs3.close();
				rs3 = null;
			}
			if (rs4 != null) {
				rs4.close();
				rs4 = null;
			}
			if (pstmt1 != null) {
				pstmt1.close();
				pstmt1 = null;
			}	
			if (pstmt2 != null) {
				pstmt2.close();
				pstmt2 = null;
			}
			if (pstmt3 != null) {
				pstmt3.close();
				pstmt3 = null;
			}
			if (pstmt4 != null) {
				pstmt4.close();
				pstmt4 = null;
			}		
			if (conn != null) {
				conn.close();
				conn = null;
			}
		}
%>

</body>
</html>